Skip to content

IDE: Markdown preview to the side (#179) - #239

Merged
aMonteSl merged 2 commits into
v1.2.1from
claude/project-thread-krb4ko
Nov 27, 2026
Merged

aMonteSl merged 2 commits into
v1.2.1from
claude/project-thread-krb4ko

Conversation

@aMonteSl

@aMonteSl aMonteSl commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #179 (epic #163).

What

Open Preview to the Side (Ctrl/Cmd+K V, also in the tab menu of a Markdown file) opens a pane to the right of the editor groups that renders the active Markdown file. It supports GitHub-flavoured Markdown: headings, lists, task lists, tables, images, and code blocks coloured by Monaco's tokenizer.

  • Live: the preview re-renders as you type.
  • Scroll sync: it follows the editor's scroll. Each top-level block knows the source line it starts on.
  • Follows the active file: it takes over whichever Markdown file becomes active.
  • Theme: it uses the workbench colours, so light and dark both work.
  • Resizable: it has its own sash, which drags and resets on double-click.

Safety

The preview is the only place in the renderer that inserts parsed markup, so it is fenced in several ways:

  • Sanitising: a dedicated DOMPurify instance processes everything marked produces. It removes <script>, <style>, the style attribute, forms and frames, and prefixes document ids (SANITIZE_NAMED_PROPS). The config is passed on every call, because DOMPurify ignores per-call options once setConfig has been used. Task-list checkboxes are kept, disabled.
  • CSP: the window's CSP is unchanged.
  • Images: they are rewritten while still in DOMPurify's inert document, so nothing is fetched.
    • An image of the open folder is read by the main process through the new workspace.readImage. It is checked against the folder, limited to raster formats (no SVG) and 8 MB, and inlined as a data: URL.
    • A remote image becomes a link that opens it in the browser, so the preview never goes online.
  • Links: a #heading link scrolls the preview, and a relative link opens the file in the IDE. Only http, https and mailto links leave the IDE, through the new workspace.openExternalLink, whose scheme the main process checks. Nothing navigates the window.

New dependencies for the IDE workspace: marked 14.0.0 and dompurify 3.4.15. Both were already in the lock file as Monaco's dependencies, so the lock only gains the workspace entries. Both are added to THIRD_PARTY_NOTICES.md.

Plugin: no change. VS Code previews Markdown natively.

Verified

  • npm test at the root passes: 1,286 extension tests and 616 IDE tests. The new markdown.test.ts covers block lines, reference links, link and image classification, slugs, readImage (folder only, no SVG) and isOpenableExternalLink.
  • npm run ide:smoke passes.
  • Playwright on Linux at 1280x800, in dark and light themes, checked these:
    • Headings render with ids, along with nested and task lists, a table, and a Python block coloured by Monaco.
    • A PNG from the folder is inlined, and a remote badge becomes a link.
    • Malicious HTML is neutralised: <script>, <img onerror>, <style>body{display:none}</style> and a javascript: link. No flag was set and the page stayed visible.
    • The preview updates live while typing and follows the editor's scroll.
    • A relative link opened docs/api.md, and the preview followed it.
    • The close button works.
    • The page never scrolls sideways.

One thing found during testing: an <img> with an invalid src and an onerror handler makes Chromium report a script-src-attr CSP violation while DOMPurify parses it in its inert document. Nothing executes. The CSP is the backstop it is meant to be.

Not implemented: the preview is not part of the saved tab session.

Ctrl/Cmd+K V renders the active Markdown file in a pane beside the editor
groups: live while typing, scroll-synced, theme colours, code blocks
coloured by Monaco. Sanitised with DOMPurify; folder images inlined by the
main process (raster only), remote images become links, relative links
open files, only http(s)/mailto leave the IDE.
@aMonteSl aMonteSl self-assigned this Nov 27, 2026
@aMonteSl
aMonteSl merged commit efe87ff into v1.2.1 Nov 27, 2026
15 checks passed
@aMonteSl aMonteSl mentioned this pull request Nov 27, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants